TreasureBoat Blog

Adding Sample Code and Solutions. Also watch TB News on your TB To Go or TB Desktop App.

Thread Safety


Image

What is thread safety ?

First check this article written by Gowthamy Vaseekaran

Concurrent Programming Fundamentals

So now after we understand the concept, the problem was the Encryption and Hash feature was not really thread safe. And after we had a problem and with great help from @mark we started investigating into it and fixed all the code to make it Thread safe.

Example for Hashing

String plainText = "Hello TreasureBoat";

MD5

TBFString.md5_asHex(plainText));
TBFString.md5_asBase64(plainText));

SHA1

TBFString.sha1_asHex(plainText));
TBFString.sha1_Base64(plainText));

SHA3-224

TBFString.sha3_224_asHex(plainText));
TBFString.sha3_224_Base64(plainText));

SHA3-256

TBFString.sha3_256_asHex(plainText));
TBFString.sha3_256_Base64(plainText));

SHA3-384

TBFString.sha3_384_asHex(plainText));
TBFString.sha3_384_Base64(plainText));

SHA3-512

TBFString.sha3_512_asHex(plainText));
TBFString.sha3_512_Base64(plainText));

Example for Encrypt

String encryptText1 = TBFStrongTextEncryptor.of(plainText).encrypt();
String encryptText2 = TBFStrongTextEncryptor.of(plainText).encryptAsBase64();       
String encryptText3  = TBFStrongTextEncryptor.of(plainText).encryptAsHex();

Example for Decrypt

TBFStrongTextEncryptor.of(encryptText1).decrypt());
TBFStrongTextEncryptor.of(encryptText2).decrypt());
TBFStrongTextEncryptor.of(encryptText3).decrypt());

So now you have seen the new commands in TB, old Hash command are removed now. and some old Encryption is still there just in case you have something to decrypt.

Wish you happy developing.

 06/10/2021
 ishimoto
 Tokyo